using Microsoft.AspNetCore.Mvc;

namespace DesktopWidgetApp.Server.API.Controllers
{
    /// <summary>
    /// 测试控制器
    /// 用于验证服务器连接和基本功能
    /// </summary>
    [ApiController]
    [Route("api/[controller]")]
    public class TestController : ControllerBase
    {
        /// <summary>
        /// 测试服务器连接
        /// </summary>
        /// <returns>返回服务器状态信息</returns>
        [HttpGet("ping")]
        public IActionResult Ping()
        {
            return Ok(new { Status = "Server is running", Time = DateTime.Now });
        }
        
        /// <summary>
        /// 获取服务器信息
        /// </summary>
        /// <returns>返回服务器版本和环境信息</returns>
        [HttpGet("info")]
        public IActionResult GetServerInfo()
        {
            var info = new
            {
                Version = "1.0.0",
                Environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Production",
                MachineName = Environment.MachineName,
                Timestamp = DateTime.Now
            };
            
            return Ok(info);
        }
    }
}